package br.fxfc.android.daysuntil;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBHelper extends SQLiteOpenHelper {

	// Constantes do Banco de Dados
	private static final String DB_NAME = "daysuntil.db";
	private static final int DB_VERSION = 1;
	private static final String TAG = "DBHelper";

	// Constantes da tabela
	public static class TableDaysUntil {
		protected static final String NAME = "daysuntil";
		protected static final String COL_TEXT = "texto";
		protected static final String COL_DATETIME = "data";
		protected static final String COL_PASSED = "passou";
	}

	public DBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		Log.d(TAG, "DBHelper(): exit");
	}

	@Override
	public void onCreate(SQLiteDatabase sqlDB) {
		Log.d(TAG, "onCreate(): enter");
		String sql = "create table " + TableDaysUntil.NAME
				+ " (_id integer not null primary key autoincrement, "
				+ TableDaysUntil.COL_TEXT + " varchar(100), "
				+ TableDaysUntil.COL_DATETIME + " datetime, "
				+ TableDaysUntil.COL_PASSED + " bit) ";
		sqlDB.execSQL(sql);
		Log.d(TAG, "onCreate(): sql= " + sql);
		Log.d(TAG, "onCreate(): exit");
	}

	@Override
	public void onUpgrade(SQLiteDatabase sqlDB, int versionFrom, int versionTo) {
		// TODO Auto-generated method stub]
		Log.d(TAG, "onUpgrade(): enter");
		String sql = "no data here";
		Log.d(TAG, "onUpgrade(): sql= " + sql);
		Log.d(TAG, "onUpgrade(): exit");
	}
}
